import { getEncryptString, getDecryptString } from "../../defaut";
const password = "123456";
export default {
  // 储存
  setStorage(key, val) {
    try {
      val = typeof val !== "string" ? JSON.stringify(val) : val;
      uni.setStorageSync(key, getEncryptString(val, password));
    } catch (err) {
      return false;
    }
  },
  // 获取
  getStorage(key) {
    try {
      return JSON.parse(getDecryptString(uni.getStorageSync(key), password));
    } catch (err) {}
  },
  // 删除
  removeStorage(key) {
    uni.removeStorageSync(key);
  },
  // 清楚缓存
  clearStorage() {
    uni.clearStorageSync();
  },
};
